#include <cstdlib>
#include <iostream>
#include <fstream>
#include "enum.h"

extern void UserRead(bool First);
extern void UserWrite();
extern void PwrRead();
extern void ReadName();
extern void GetCmd();
extern void AutoSave();
extern void Welcome();
extern void GetMap();

using namespace std;

int UserStat[8];
int DeptStat[8];
int PwrStat[10];
int DeptPwr[10];
int SaveCount(0);
string Name;
string Cmd;
int Pass;
bool Wel = true;
bool Muye = false;
bool Yu = false;
bool temp1;
bool temp2;
bool temp3;
bool temp4;
bool temp5;


int main(int argc, char *argv[])
{
    srand(time(NULL));
    int Choice;
    char Erase;
    cout << "Welcome to Atiri - Defeat the Nian(MUD)\n";
    cout << "By: Siyuan Gao\n";
    cout << "=====================================\n";
    cout << "Please select:\n";
    cout << "(1)New User\n";
    cout << "(2)Existing User\n";
    cin >> Choice;
    switch(Choice)
    {
                  case 1:
                       cout << "Existing User will be deleted! Continue? (Y/N)";
                       cin >> Erase;
                       if((Erase == 'Y') ||(Erase == 'y'))
                       UserRead(1);
                       else
                       UserRead(0);
                       break;
                  case 2:
                       UserRead(0);
                       PwrRead();
                       ReadName();
                       cout << "\nWelcome " << Name << " !\n";
                       system("pause");
                       Wel = false;
                       break;
                  default:
                          cout << "Wrong Selection!\n";
                          exit(1);
    }
    system("cls");
    do
    {
     if(Wel)
     {
      Welcome();
      Wel = false;
     }
     GetMap();
     GetCmd();
     SaveCount++;
     if((SaveCount % 5) == 0)
     {
     AutoSave();
     SaveCount = 0;
     }
    }
    while(atoi(Cmd.c_str()) != EXIT);
    cout << "Your progress is saved! Good Bye~\n" << endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}
